﻿    using FinancePortal.Business.Infraestructure;
using FinancePortal.Business.Repository;
using FinancePortal.Domain.Model;
using System.Collections.Generic;
using System.Linq;

namespace FinancePortal.Business.Implementation
{
    public class ResourceRepository : RepositoryBase<Resource>, IResourceRepository
    {
        public ResourceRepository(IUnitOfWork uow)
            : base(uow)
        { }

        public IQueryable<Resource> GetByArea(int? areaId) //(IList<int> areas)
        {
            return (from r in GetAll()
                    where areaId == 1 || r.Area.Id == areaId //!areaId.HasValue || r.Area.Id == areaId
                    select r);
        }

        public Resource GetBySOEID(string SOEID)
        {
            return (from r in GetAll()
                    where r.SOEID == SOEID
                    select r).Single();
        }

    }
}
